
import style from "./index.module.scss"
import { translate } from '@/utils/Translate.ts'
import {Button, Input} from "antd"
import {ChangeEvent, useRef} from "react";

const { TextArea } = Input;
const Popup = () => {
  const value = useRef<string>('')
  const onValueChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
    value.current = event.target.value
  }
  const onTranslate = async () => {
    try {
      const res = await translate(value.current, 'zh', 'en')
      console.log(res)
    } catch (error) {
      console.error(error)
    }
  }
  return (
    <div className={style.root}>
      <Button onClick={onTranslate}>翻译</Button>
      <TextArea onChange={onValueChange}></TextArea>
    </div>
  )
}

export  default Popup
